<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    CSS3_three.md |  Small Bridge
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/css/main.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

  

<link rel="alternate" href="/atom.xml" title="Small Bridge" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content">
      <section class="outer">
  <article id="css3_two.md-CSS3-three-md" class="article article-type-css3_two.md" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  CSS3_three.md
</h1>
  

    </header>
    

    
    <div class="article-meta">
      <a href="/2020/05/14/CSS3-three-md/" class="article-date">
  <time datetime="2020-05-14T13:14:29.000Z" itemprop="datePublished">2020-05-14</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/categories/CSS/">CSS</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">3k字</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">14分钟</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      


      

      
      <p>@<a href="CSS3">TOC</a></p>
<h1 id="过渡"><a href="#过渡" class="headerlink" title="过渡"></a>过渡</h1><a id="more"></a>
<p>transition：提供了一种在更改CSS属性时控制动画速度的方法，其可以让属性变化成为一个持续一段时间的过程，而不是立即生效的，它是一个简写属性</p>
<ol>
<li><p>API介绍<br>transition-property 指定要产生过渡效果的属性，有些属性不能产生过渡效果，比如display<br>transition-duration 指定过渡持续的时间，必须带单位<br>transition-timing-function 指定过渡运动的形式<br>transition-delay 指定过渡效果开始之前的延迟时间</p>
</li>
<li><p>注意点</p>
</li>
<li><p>1 当属性值对应不一致的时候:<br>transition-property:  width height color;<br>transition-duration: 1s 2s;<br>transition-timing-function: ease linear;<br>transition-delay: 1s 2s;<br>时间列表会重复，并将多余的截去，而运动形式则采用默认值ease，(1s 2s)重复成(1s 2s 1s 2s)将1s给color，将多余的2s截去，color的运动形式直接采用默认值ease</p>
</li>
<li><p>2 0也一定要带单位<br>transition-duration: 0 和 transition-duration: 0s 区别很大</p>
</li>
<li><p>过渡事件<br>当过渡效果完成时触发一个事件，在符合标准的浏览器下，这个事件是transitionend，在webkit内核下是webkitTransitionEnd<br>每一个拥有过渡的属性在其完成过渡时都会触发一次transitionend事件<br>在transitionend完成前设置display:none，事件不会触发</p>
</li>
<li><p>过渡的天坑</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			*&#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			html&#123;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			body&#123;</span></span><br><span class="line"><span class="string">				height: 60%;</span></span><br><span class="line"><span class="string">				width: 60%;</span></span><br><span class="line"><span class="string">				margin: 100px auto 0;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			#test&#123;</span></span><br><span class="line"><span class="string">				width: 200px;</span></span><br><span class="line"><span class="string">				height: 200px;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">				background: pink;</span></span><br><span class="line"><span class="string">				text-align: center;</span></span><br><span class="line"><span class="string">				font: 30px/200px "</span>微软雅黑<span class="string">";</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				transition-property: width;</span></span><br><span class="line"><span class="string">				transition-duration: 2s;</span></span><br><span class="line"><span class="string">				transition-timing-function: linear;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			body:hover #test&#123;</span></span><br><span class="line"><span class="string">				transition-property: height;</span></span><br><span class="line"><span class="string">				width: 100px;</span></span><br><span class="line"><span class="string">				height: 100px;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">			/* 这样写鼠标悬浮是高度先变，鼠标移出宽度在变 */</span></span><br><span class="line"><span class="string">			/* 要注意的是：此时，当鼠标移入框内时，变化的并不是width，而是height；</span></span><br><span class="line"><span class="string">			当鼠标移出框内时，width进行变化。解释:这跟浏览器的渲染机制有关系，</span></span><br><span class="line"><span class="string">			浏览器真正在页面上渲染动画过程中是需要去画布局的，</span></span><br><span class="line"><span class="string">			这个过程比解析代码来得慢，导致有一个时间差。</span></span><br><span class="line"><span class="string">			浏览器第一次解析时的确是移入框内width进行变化。</span></span><br><span class="line"><span class="string">			但是，CSS代码解析的速度极快，当鼠标移入框内时，</span></span><br><span class="line"><span class="string">			触发body:hover #test中的代码，发现有transition-property: height;</span></span><br><span class="line"><span class="string">			因此就立即把内存中需要变化的width改为height；在这一过程中，</span></span><br><span class="line"><span class="string">			浏览器根本来不及进行渲染工作，因此，当渲染发生时，</span></span><br><span class="line"><span class="string">			浏览器去内存中寻找到底是哪个属性要进行过渡，此时，</span></span><br><span class="line"><span class="string">			width已经被改为height，所以渲染的时候，就直接将更改后的height进行过渡。</span></span><br><span class="line"><span class="string">			然后，当鼠标移出框外的一瞬间，浏览器发现有transition-property: width;</span></span><br><span class="line"><span class="string">			然后就立即把height改为width，这段时间内浏览器仍然由于时间太短而无法进行渲染工作，</span></span><br><span class="line"><span class="string">			因此移出时是width进行过渡</span></span><br><span class="line"><span class="string">			*/</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>test<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			123</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"UTF-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			* &#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			html &#123;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			body &#123;</span></span><br><span class="line"><span class="string">				width: 60%;</span></span><br><span class="line"><span class="string">				height: 60%;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				margin: 100px auto 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#test &#123;</span></span><br><span class="line"><span class="string">				width: 100px;</span></span><br><span class="line"><span class="string">				height: 100px;</span></span><br><span class="line"><span class="string">				background: pink;</span></span><br><span class="line"><span class="string">				text-align: center;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				/*------------以上代码用于居中、边框等--------------*/</span></span><br><span class="line"><span class="string">				transition-property: width;</span></span><br><span class="line"><span class="string">				transition-duration: 2s;</span></span><br><span class="line"><span class="string">				transition-timing-function: linear;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>test<span class="string">"&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script type="</span>text/javascript<span class="string">"&gt;</span></span><br><span class="line"><span class="string">		//transition在元素首次渲染还没有结束的情况下是不会触发的</span></span><br><span class="line"><span class="string">		window.onload = function() &#123;</span></span><br><span class="line">			var test = document.querySelector("#test");</span><br><span class="line">			<span class="comment">// 这样也没有渲染效果，因为又变成了100px，100px到100px没有过渡效果</span></span><br><span class="line">			test.style.width = <span class="string">"300px"</span>;</span><br><span class="line">			test.style.width = <span class="string">"100px"</span>;</span><br><span class="line">			<span class="comment">//</span></span><br><span class="line">			<span class="comment">/*</span></span><br><span class="line"><span class="comment">			这样也属于首次渲染，不会触发过渡效果</span></span><br><span class="line"><span class="comment">			var test = document.createElement("div");</span></span><br><span class="line"><span class="comment">			test.id = "test";</span></span><br><span class="line"><span class="comment">			document.documentElement.appendChhild(test);</span></span><br><span class="line"><span class="comment">			//这里加个2s定时器就可以</span></span><br><span class="line"><span class="comment">			test.style.width = "300px"</span></span><br><span class="line"><span class="comment">			*/</span></span><br><span class="line">		&#125;</span><br><span class="line">	&lt;<span class="regexp">/script&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>html&gt;</span><br></pre></td></tr></table></figure></li>
<li><p>过渡的简写属性<br>CSS过渡由简写属性定义是最好的方式，可以避免属性值列表长度不一，节省调试时间，但要注意，在transition属性中，各个值的书写顺序是很重要的，第一个解析成时间赋给transition-duration，第二个解析成时间的值会赋值给transition-delay延迟</p>
<h1 id="2D变换"><a href="#2D变换" class="headerlink" title="2D变换"></a>2D变换</h1><p>transform属性允许你修改CSS视觉格式模型的坐标空间<br>transform属性，只对block级元素生效</p>
</li>
<li><p>旋转<br>transform: rotate(角度) </p>
</li>
<li><p>平移<br>transform: translate(x轴偏移,Y轴偏移) 一个参数时也是X轴偏移<br>translateX(偏移量)  translateY(偏移量)</p>
</li>
<li><p>倾斜<br>skew(角度)  单值仅对X有效</p>
</li>
<li><p>缩放<br>scale(数字)  大于1放大 小于1缩小 单值X，Y均有效</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			* &#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			html &#123;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">				overflow: hidden;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			body &#123;</span></span><br><span class="line"><span class="string">				height: 60%;</span></span><br><span class="line"><span class="string">				width: 60%;</span></span><br><span class="line"><span class="string">				margin: 100px auto 0;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				overflow: hidden;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">        </span></span><br><span class="line"><span class="string">			#test &#123;</span></span><br><span class="line"><span class="string">				width: 200px;</span></span><br><span class="line"><span class="string">				height: 200px;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">				background: pink;</span></span><br><span class="line"><span class="string">				text-align: center;</span></span><br><span class="line"><span class="string">				font: 30px/200px "</span>微软雅黑<span class="string">";</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				transition: transform 1s linear;</span></span><br><span class="line"><span class="string">				/* 基点变换 基于左上角的位置变换 */</span></span><br><span class="line"><span class="string">				/* 可以写像素，也可以写百分比 */</span></span><br><span class="line"><span class="string">				/* 对平移不会造成影响 */</span></span><br><span class="line"><span class="string">				/* transform-origin: left top; */</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			body:hover #test &#123;</span></span><br><span class="line"><span class="string">				transform: rotate(360deg);</span></span><br><span class="line"><span class="string">				/* transform: translateX(100px); */</span></span><br><span class="line"><span class="string">				/* transform: skew(45deg); */</span></span><br><span class="line"><span class="string">				/* transform: scale(1.5); */</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>test<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			123</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>基点的变换<br>transform-origin: left top;    //基于左上角进行变换</p>
<pre><code>10px 10px;  //基于(10px 10px)的位置进行变换
10% 10%;   //基于自身(10% 10%)的位置进行变换</code></pre></li>
<li><p>2D变换组合<br>变换的本质是矩阵的计算，对应的变换就是乘以对应变换的矩阵<br>transform: rotate(45deg) translateX(100px)<br>transform: translateX(100px) rotate(45deg)<br>变换组合的计算方式是从右往左进行计算，第一个是先乘以X轴平移的矩阵，再乘以旋转的矩阵，第二个是先乘以旋转的矩阵，再乘以X轴平移的矩阵<br>二者的效果不同，因为矩阵乘法不满足交换律</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			* &#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			html &#123;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">				overflow: hidden;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			body &#123;</span></span><br><span class="line"><span class="string">				height: 60%;</span></span><br><span class="line"><span class="string">				width: 60%;</span></span><br><span class="line"><span class="string">				margin: 100px auto 0;</span></span><br><span class="line"><span class="string">				border: 1px solid;</span></span><br><span class="line"><span class="string">				overflow: hidden;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#test &#123;</span></span><br><span class="line"><span class="string">				width: 200px;</span></span><br><span class="line"><span class="string">				height: 200px;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">				background: pink;</span></span><br><span class="line"><span class="string">				text-align: center;</span></span><br><span class="line"><span class="string">				font: 30px/200px "</span>微软雅黑<span class="string">";</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				margin: auto;</span></span><br><span class="line"><span class="string">				transition: 1s;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			body:hover #test &#123;</span></span><br><span class="line"><span class="string">				/* 变换组合都是从右往左进行计算的 */</span></span><br><span class="line"><span class="string">				/* 变换的本质是矩阵的计算，对应的变换就是乘以对应变换矩阵 */</span></span><br><span class="line"><span class="string">				transform: translateX(200px) rotate(360deg);</span></span><br><span class="line"><span class="string">				/* 两者变换效果，大不同，因为矩阵乘法不满足交换律 */</span></span><br><span class="line"><span class="string">				/* transform: rotate(360deg) translateX(200px); */</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>test<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			123</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">&lt;/html&gt;</span></span><br></pre></td></tr></table></figure>
<p>综合应用<br>时钟</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			* &#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				/* 钟盘居中，没什么好说的 */</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 50%;</span></span><br><span class="line"><span class="string">				top: 50%;</span></span><br><span class="line"><span class="string">				margin-top: -100px;</span></span><br><span class="line"><span class="string">				margin-left: -100px;</span></span><br><span class="line"><span class="string">				width: 200px;</span></span><br><span class="line"><span class="string">				height: 200px;</span></span><br><span class="line"><span class="string">				border: 1px solid black;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;ul &#123;</span></span><br><span class="line"><span class="string">				list-style: none;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;ul&gt;li &#123;</span></span><br><span class="line"><span class="string">				/* 移动到12点的位置 */</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				left: 99px;</span></span><br><span class="line"><span class="string">				width: 2px;</span></span><br><span class="line"><span class="string">				height: 10px;</span></span><br><span class="line"><span class="string">				background: #000000;</span></span><br><span class="line"><span class="string">				/* 旋转的基点调整为钟盘的圆心 */</span></span><br><span class="line"><span class="string">				transform-origin: center 100px;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;ul&gt;li:nth-child(5n+1) &#123;</span></span><br><span class="line"><span class="string">				/* 长针怼出来 */</span></span><br><span class="line"><span class="string">				height: 15px;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.hour &#123;</span></span><br><span class="line"><span class="string">				/* left:100-width/2 */</span></span><br><span class="line"><span class="string">				/* top:100-height */</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 97px;</span></span><br><span class="line"><span class="string">				top: 70px;</span></span><br><span class="line"><span class="string">				width: 6px;</span></span><br><span class="line"><span class="string">				height: 30px;</span></span><br><span class="line"><span class="string">				background: black;</span></span><br><span class="line"><span class="string">				/* 基点为自己的`尾巴` */</span></span><br><span class="line"><span class="string">				transform-origin: center bottom;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.minute &#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 98px;</span></span><br><span class="line"><span class="string">				top: 50px;</span></span><br><span class="line"><span class="string">				width: 4px;</span></span><br><span class="line"><span class="string">				height: 50px;</span></span><br><span class="line"><span class="string">				background: gray;</span></span><br><span class="line"><span class="string">				transform-origin: center bottom;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.second &#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 99px;</span></span><br><span class="line"><span class="string">				top: 30px;</span></span><br><span class="line"><span class="string">				width: 2px;</span></span><br><span class="line"><span class="string">				height: 70px;</span></span><br><span class="line"><span class="string">				background: red;</span></span><br><span class="line"><span class="string">				transform-origin: center bottom;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.icon &#123;</span></span><br><span class="line"><span class="string">				/* left:100-width/2 */</span></span><br><span class="line"><span class="string">				/* top:100-height/2 */</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 90px;</span></span><br><span class="line"><span class="string">				top: 90px;</span></span><br><span class="line"><span class="string">				width: 20px;</span></span><br><span class="line"><span class="string">				height: 20px;</span></span><br><span class="line"><span class="string">				background: pink;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;ul&gt;</span></span><br><span class="line"><span class="string">			&lt;/ul&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>hour<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>minute<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>second<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>icon<span class="string">"&gt;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script type="</span>text/javascript<span class="string">"&gt;</span></span><br><span class="line"><span class="string">		// 获取相关操作节点</span></span><br><span class="line">		var hourNode = document.querySelector("#wrap&gt;.hour");</span><br><span class="line">		<span class="keyword">var</span> minuteNode = <span class="built_in">document</span>.querySelector(<span class="string">"#wrap&gt;.minute"</span>);</span><br><span class="line">		<span class="keyword">var</span> secondNode = <span class="built_in">document</span>.querySelector(<span class="string">"#wrap&gt;.second"</span>);</span><br><span class="line">		<span class="keyword">var</span> ulNode = <span class="built_in">document</span>.querySelector(<span class="string">"#wrap&gt;ul"</span>);</span><br><span class="line">		<span class="comment">//创建一个style节点</span></span><br><span class="line">		<span class="keyword">var</span> styleNode = <span class="built_in">document</span>.createElement(<span class="string">"style"</span>);</span><br><span class="line">		<span class="keyword">var</span> liHTML = <span class="string">""</span>;</span><br><span class="line">		<span class="keyword">var</span> styleHTML = <span class="string">""</span>;</span><br><span class="line">		<span class="comment">//往ul里面塞60个li，并添加旋转，每次增加旋转6度，转出一个表的刻度</span></span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; <span class="number">60</span>; i++) &#123;</span><br><span class="line">			liHTML += <span class="string">"&lt;li&gt;&lt;/li&gt;"</span>;</span><br><span class="line">			styleHTML += <span class="string">`#wrap&gt;ul&gt;li:nth-child(<span class="subst">$&#123;i+<span class="number">1</span>&#125;</span>)&#123;transform: rotate(<span class="subst">$&#123;<span class="number">6</span>*i&#125;</span>deg)&#125;`</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		ulNode.innerHTML = liHTML;</span><br><span class="line">		styleNode.innerHTML = styleHTML;</span><br><span class="line">		<span class="built_in">document</span>.head.appendChild(styleNode);</span><br><span class="line">        </span><br><span class="line">		move();</span><br><span class="line">		<span class="comment">//1s执行一次，模拟时钟一s走一下嘛</span></span><br><span class="line">		setInterval(move, <span class="number">1000</span>);</span><br><span class="line">        </span><br><span class="line">		<span class="comment">//走表函数</span></span><br><span class="line">		<span class="function"><span class="keyword">function</span> <span class="title">move</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">			<span class="comment">//获取当前时间</span></span><br><span class="line">			<span class="keyword">var</span> date = <span class="keyword">new</span> <span class="built_in">Date</span>();</span><br><span class="line">			<span class="keyword">var</span> s = date.getSeconds();</span><br><span class="line">			<span class="comment">//加上秒数的尾巴，每次分数都不一样，模拟分针每次都走嘛</span></span><br><span class="line">			<span class="keyword">var</span> m = date.getMinutes() + s / <span class="number">60</span>;</span><br><span class="line">			<span class="comment">//类似</span></span><br><span class="line">			<span class="keyword">var</span> h = date.getHours() + m / <span class="number">60</span>;</span><br><span class="line">            </span><br><span class="line">			<span class="comment">//时针一个小时走360/12=30°</span></span><br><span class="line">			hourNode.style.transform = <span class="string">`rotate(<span class="subst">$&#123;h*<span class="number">30</span>&#125;</span>deg)`</span>;</span><br><span class="line">			<span class="comment">//分针一分钟6°</span></span><br><span class="line">			minuteNode.style.transform = <span class="string">`rotate(<span class="subst">$&#123;m*<span class="number">6</span>&#125;</span>deg)`</span>;</span><br><span class="line">			<span class="comment">//秒针一秒6°</span></span><br><span class="line">			secondNode.style.transform = <span class="string">`rotate(<span class="subst">$&#123;s*<span class="number">6</span>&#125;</span>deg)`</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&lt;<span class="regexp">/script&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>html&gt;</span><br></pre></td></tr></table></figure>

</li>
</ol>
<p>扇形导航</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br></pre></td><td class="code"><pre><span class="line">&lt;!DOCTYPE html&gt;</span><br><span class="line">&lt;html&gt;</span><br><span class="line">	&lt;head&gt;</span><br><span class="line">		&lt;meta charset=<span class="string">"utf-8"</span>&gt;</span><br><span class="line">		&lt;title&gt;&lt;<span class="regexp">/title&gt;</span></span><br><span class="line"><span class="regexp">		&lt;style type="text/</span>css<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			* &#123;</span></span><br><span class="line"><span class="string">				margin: 0;</span></span><br><span class="line"><span class="string">				padding: 0;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap &#123;</span></span><br><span class="line"><span class="string">				height: 50px;</span></span><br><span class="line"><span class="string">				width: 50px;</span></span><br><span class="line"><span class="string">				position: fixed;</span></span><br><span class="line"><span class="string">				right: 0;</span></span><br><span class="line"><span class="string">				bottom: 0;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.inner &#123;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;.inner&gt;img &#123;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				margin: 4px;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#wrap&gt;#home &#123;</span></span><br><span class="line"><span class="string">				width: 100%;</span></span><br><span class="line"><span class="string">				height: 100%;</span></span><br><span class="line"><span class="string">				position: absolute;</span></span><br><span class="line"><span class="string">				left: 0;</span></span><br><span class="line"><span class="string">				top: 0;</span></span><br><span class="line"><span class="string">				z-index: 1;</span></span><br><span class="line"><span class="string">				transition: 1.5s;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">			#home&gt;img &#123;</span></span><br><span class="line"><span class="string">				border-radius: 50%;</span></span><br><span class="line"><span class="string">			&#125;</span></span><br><span class="line"><span class="string">		&lt;/style&gt;</span></span><br><span class="line"><span class="string">	&lt;/head&gt;</span></span><br><span class="line"><span class="string">	&lt;body&gt;</span></span><br><span class="line"><span class="string">		&lt;div id="</span>wrap<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;div class="</span>inner<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/clos.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/full.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/open.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/prev.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/refresh.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">			&lt;div id="</span>home<span class="string">"&gt;</span></span><br><span class="line"><span class="string">				&lt;img src="</span>img/home.png<span class="string">"&gt;</span></span><br><span class="line"><span class="string">			&lt;/div&gt;</span></span><br><span class="line"><span class="string">		&lt;/div&gt;</span></span><br><span class="line"><span class="string">	&lt;/body&gt;</span></span><br><span class="line"><span class="string">	&lt;script type="</span>text/javascript<span class="string">"&gt;</span></span><br><span class="line"><span class="string">		window.onload = function() &#123;</span></span><br><span class="line">			var homeElem = document.querySelector("#home");</span><br><span class="line">			<span class="keyword">var</span> imgs = <span class="built_in">document</span>.querySelectorAll(<span class="string">"#wrap&gt;.inner&gt;img"</span>);</span><br><span class="line">			<span class="keyword">var</span> c = <span class="number">140</span>;</span><br><span class="line">			<span class="keyword">var</span> flag = <span class="literal">true</span>;</span><br><span class="line">			<span class="comment">//第二部分(点击放大并缩回去)</span></span><br><span class="line">			<span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; imgs.length; i++) &#123;</span><br><span class="line">				imgs[i].onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">					<span class="comment">//存在闭包，里面不要用i，用this</span></span><br><span class="line">					<span class="comment">//注意点1：记得重置一下，因为下面也操作了img，并增加了延迟</span></span><br><span class="line">					<span class="comment">//这里应该取消掉延迟</span></span><br><span class="line">					<span class="keyword">this</span>.style.transition = <span class="string">"0.5s"</span>;</span><br><span class="line">					<span class="comment">//为了防止样式切换时对应不一致，导致效果失效</span></span><br><span class="line">					<span class="comment">//transform覆盖的时候应该带上上次的状态</span></span><br><span class="line">					<span class="comment">//这是最笨的办法，我们可以自己封装一个函数处理,抱歉，我不会</span></span><br><span class="line">					<span class="keyword">this</span>.style.transform = <span class="string">"rotate(-720deg) scale(2)"</span>;</span><br><span class="line">					<span class="keyword">this</span>.style.opacity = <span class="number">0.1</span>;</span><br><span class="line">					<span class="comment">//过渡结束就会触发的事件，必须放在这个函数里面</span></span><br><span class="line">					<span class="comment">//不然外面的过渡效果结束，也会来触发这个事件</span></span><br><span class="line">					<span class="keyword">this</span>.addEventListener(<span class="string">"transitionend"</span>, fn);</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="function"><span class="keyword">function</span> <span class="title">fn</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">				<span class="keyword">this</span>.style.transition = <span class="string">"0.3s"</span>;</span><br><span class="line">				<span class="keyword">this</span>.style.transform = <span class="string">"rotate(-720deg) scale(1)"</span>;</span><br><span class="line">				<span class="keyword">this</span>.style.opacity = <span class="number">1</span>;</span><br><span class="line">				<span class="comment">//因为事件一旦绑定就不会消失，这样其他的过渡效果也会触发这个事件</span></span><br><span class="line">				<span class="comment">//所以应该解绑</span></span><br><span class="line">				<span class="keyword">this</span>.removeEventListener(<span class="string">"transitionend"</span>, fn);</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="comment">//第一部分(导航出现和消失)</span></span><br><span class="line">			homeElem.onclick = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</span><br><span class="line">				<span class="keyword">if</span> (flag) &#123;</span><br><span class="line">					<span class="keyword">this</span>.style.transform = <span class="string">"rotate(-720deg)"</span>;</span><br><span class="line">					<span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; imgs.length; i++) &#123;</span><br><span class="line">						imgs[i].style.transition = <span class="string">`1s <span class="subst">$&#123;i*<span class="number">0.1</span>&#125;</span>s`</span>;</span><br><span class="line">						imgs[i].style.transform = <span class="string">"rotate(-720deg) scale(1)"</span>;</span><br><span class="line">						imgs[i].style.top = -getPosition(c, <span class="number">90</span> * i / (imgs.length - <span class="number">1</span>)).top + <span class="string">"px"</span>;</span><br><span class="line">						imgs[i].style.left = -getPosition(c, <span class="number">90</span> * i / (imgs.length - <span class="number">1</span>)).left + <span class="string">"px"</span>;</span><br><span class="line">					&#125;</span><br><span class="line">				&#125; <span class="keyword">else</span> &#123;</span><br><span class="line">					<span class="keyword">this</span>.style.transform = <span class="string">"rotate(0deg) scale(1)"</span>;</span><br><span class="line">					<span class="keyword">for</span> (<span class="keyword">let</span> i = <span class="number">0</span>; i &lt; imgs.length; i++) &#123;</span><br><span class="line">						imgs[i].style.transition = <span class="string">`1s <span class="subst">$&#123;(imgs.length<span class="number">-1</span>-i)*<span class="number">0.1</span>&#125;</span>s`</span>;</span><br><span class="line">						imgs[i].style.transform = <span class="string">"rotate(0deg)"</span>;</span><br><span class="line">						imgs[i].style.top = <span class="number">0</span>;</span><br><span class="line">						imgs[i].style.left = <span class="number">0</span>;</span><br><span class="line">					&#125;</span><br><span class="line">				&#125;</span><br><span class="line">				flag = !flag;</span><br><span class="line">			&#125;</span><br><span class="line"></span><br><span class="line">			<span class="function"><span class="keyword">function</span> <span class="title">getPosition</span>(<span class="params">c, deg</span>) </span>&#123;</span><br><span class="line">				<span class="keyword">var</span> x = <span class="built_in">Math</span>.round(c * <span class="built_in">Math</span>.sin(deg * <span class="built_in">Math</span>.PI / <span class="number">180</span>));</span><br><span class="line">				<span class="keyword">var</span> y = <span class="built_in">Math</span>.round(c * <span class="built_in">Math</span>.cos(deg * <span class="built_in">Math</span>.PI / <span class="number">180</span>));</span><br><span class="line">				<span class="keyword">return</span> &#123;</span><br><span class="line">					left: x,</span><br><span class="line">					top: y</span><br><span class="line">				&#125;;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&lt;<span class="regexp">/script&gt;</span></span><br><span class="line"><span class="regexp">&lt;/</span>html&gt;</span><br></pre></td></tr></table></figure>
<p>好了，我的分享就到这里了，谢谢大家</p>

      
      <!-- reward -->
      
      <div id="reward-btn">
        打赏
      </div>
      
    </div>
    
    
      <!-- copyright -->
      
        <div class="declare">
          <ul class="post-copyright">
            <li>
              <i class="ri-copyright-line"></i>
              <strong>版权声明： </strong s>
              本博客所有文章除特别声明外，均采用 <a href="https://www.apache.org/licenses/LICENSE-2.0.html" rel="external nofollow"
                target="_blank">Apache License 2.0</a> 许可协议。转载请注明出处！
            </li>
          </ul>
        </div>
        
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://lockme.gitee.io/2020/05/14/CSS3-three-md/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/CSS3/" rel="tag">CSS3</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%96%B0%E5%86%85%E5%AE%B9/" rel="tag">新内容</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
      <a href="/2020/05/14/CSS3-two-md/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            CSS3_two.md
          
        </div>
      </a>
    
    
      <a href="/2020/05/14/CSS3-one-md/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">CSS3_one.md</div>
      </a>
    
  </nav>


  

  
  
<!-- valine评论 -->
<div id="vcomments-box">
    <div id="vcomments">
    </div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src='https://cdn.jsdelivr.net/npm/valine@1.3.10/dist/Valine.min.js'></script>
<script>
    new Valine({
        el: '#vcomments',
        app_id: 'pmaQYnbUE9O0H1hiYKLiec4R-gzGzoHsz',
        app_key: 'LMujtI79W4vgEQ3Az5IMo50y',
        path: window.location.pathname,
        notify: 'false',
        verify: 'false',
        avatar: 'mp',
        placeholder: '给我的文章加点评论吧~',
        recordIP: true
    });
    const infoEle = document.querySelector('#vcomments .info');
    if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
        infoEle.childNodes.forEach(function (item) {
            item.parentNode.removeChild(item);
        });
    }
</script>
<style>
    #vcomments-box {
        padding: 5px 30px;
    }

    @media screen and (max-width: 800px) {
        #vcomments-box {
            padding: 5px 0px;
        }
    }

    #vcomments-box #vcomments {
        background-color: #fff;
    }

    .v .vlist .vcard .vh {
        padding-right: 20px;
    }

    .v .vlist .vcard {
        padding-left: 10px;
    }
</style>

  

  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul class="list-inline">
      <li>
        &copy;
        2020
        月下ctrlc
      </li>
      <li>
        
        Powered by
        
        
        <a href="https://hexo.io" target="_blank">Hexo</a> Theme <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul class="list-inline">
      <li>
        
        
        <span>
  <i>PV:<span id="busuanzi_value_page_pv"></span></i>
  <i>UV:<span id="busuanzi_value_site_uv"></span></i>
</span>
        
      </li>
      
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="to_top">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>
      </div>
    </main>
    <aside class="sidebar">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/avatar.jpg" alt="Small Bridge"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/Vue/">Vue</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="http://shenyu-vip.lofter.com" target="_blank" rel="noopener">主题作者相册</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2020/03/18/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>拿钱砸死我吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.png">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.png">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/share.js"></script>


<script src="/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto',
    onClick: (e) => {
      $('.toc-link').removeClass('is-active-link');
      $(`a[href=${e.target.hash}]`).addClass('is-active-link');
      $(e.target.hash).scrollIntoView();
      return false;
    }
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/js/ayer.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>



<script src="/js/busuanzi-2.3.pure.min.js"></script>



<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>


    
  </div>
</body>

</html>